package com.wyx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wyx.constans.Constans;
import com.wyx.domain.SimpleUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wyx.mapper.MenuMapper;
import com.wyx.domain.Menu;
import com.wyx.service.MenuService;
/**
 * @author  xiaoxiong
 * @date  2021/2/24 19:38
 * @version 1.0
 */
@Service
public class MenuServiceImpl  implements MenuService{
    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> selectMuneTree(boolean isAdmin, SimpleUser simpleUser) {
        QueryWrapper<Menu> qw = new QueryWrapper<>();
        qw.eq(Menu.COL_STATUS, Constans.STATUS_TRUE);
        qw.in(Menu.COL_MENU_TYPE,Constans.MENU_TYPE_M,Constans.MENU_TYPE_C);
        qw.orderByAsc(Menu.COL_PARENT_ID);

        if(isAdmin){
            return menuMapper.selectList(qw);
        }else {
            // 根据用户id 查询用户拥有的菜单信息
            return menuMapper.selectList(qw);

        }
    }
}
